﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.User.AddUser>" %>

<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    添加会员
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <link href='<%=Url.Content("~/Scripts/UI/blitzer/jquery-ui-1.8.custom.css") %>' rel="stylesheet" type="text/css" />
    <script src='<%=Url.Content("~/Scripts/jquery-ui-1.8.custom.min.js") %>' type="text/javascript"></script>
    <script src='<%=Url.Content("~/Scripts/jquery.validate.errormsg.js") %>' type="text/javascript"></script>
    <script src='<%=Url.Content("~/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //            $("#div_options").tabs();
            $("#adduserform").validate();
            //            $(".rtsubhaid").each(function () {
            //                var td = $(this).find("td:first");
            //                td.css("cursor", "pointer");
            //                td.click(function () {
            //                    var tb = td.parent().parent();
            //                    var state = tb.find("tr:not(:first)").is(":hidden");
            //                    if (state) {
            //                        tb.find("tr:not(:first)").show();
            //                        td.find("div").text(" -");
            //                        td.parent().find("td").css("border-bottom", "solid 1px #888")
            //                    } else {
            //                        tb.find("tr:not(:first)").hide();
            //                        td.find("div").text("+");
            //                        td.parent().find("td").css("border-bottom", "0px")
            //                    }
            //                });
            //                var tr = td.parent().parent().find("tr:not(:first)");
            //                tr.hide();
            //                if (tr.find(":text.input-validation-error").length)
            //                    tr.show();
            //            });

            //            $("input[modelid]").change(function () {
            //                var item = $(this);
            //                var modelid = item.attr("modelid");
            //                str = item.attr("cktype");
            //                var cktype = null;
            //                if (str != undefined) {
            //                    cktype = eval("(" + str + ")");
            //                }
            //                var num = _ParseDouble(this.value);
            //                if (num == null || num < 0)
            //                    return;
            //                else {
            //                    item.parent().parent().parent().find(".td" + modelid + " :text").each(function () {
            //                        if (cktype != null) {
            //                            str = $(this).attr("playtype");
            //                            var flag = false;
            //                            for (var i in cktype.play) {
            //                                var item = cktype.play[i];
            //                                if (item == str) {
            //                                    flag = true;
            //                                    break;
            //                                }
            //                            }
            //                            if ((flag == true && cktype.contain == true) || (cktype.contain == false && flag == false)) {
            //                                this.value = num;
            //                            }
            //                        } else {
            //                            var tp = _ParseDouble($(this).attr("oldvalue"));
            //                            str = num.div(100).mul(tp);
            //                            this.value = str;
            //                        }
            //                        $(this).valid();
            //                    });
            //                }
            //            }).keypress(function (e) {
            //                if (e.keyCode == 13) {
            //                    e.keyCode = 9;
            //                    this.blur();
            //                    return false;
            //                }
            //            });
            var div = $('.div_AddChildConfig');
            div.hide();
        });
        var flag = false;
        var enableAcc = _ParseBool('<%=Model.EnableAddChildConfig %>');
        var temp = _ParseInt('11');
        function rdo_click(p) {
            var div = $('.div_AddChildConfig');
            if (p == 0) {
                div.hide();
                flag = false;
            } else if(enableAcc) {
                div.show();
                flag = true;
            }
    }
    function btnSubmit_Click() {
//        if (enableAcc) {
//            var AllChildCount = $('#AllChildCount');
//            if (flag && parseInt(AllSurrogateCount.value) > parseInt(AllChildCount.value)) {
//                alert("所有代理配额不能大于所有下级配额!");
//                return false;
//            }
//        }
        return confirm('确定提交吗？');
    }
    </script>
    <style type="text/css">
    .ui-widget-header {
    background: none;
    border: none;
    }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.DisableClientValidation(); %>
    <% Html.BeginForm(new { id = "adduserform" },null); %>
    <fieldset>
        <legend>添加用户</legend>
        <%=Html.ValidationMessage("Error") %>
        <ul class="editlist">
            <li>
                <label class="label">
                    会员级别：</label>
                <span class="spans">
                    <%= Html.RadioButtonFor(p => p.Type, Code.Models.UserType.Member, new { id = "Type_Member", onclick = "rdo_click(0)" })%>
                    <%= UserType.Member.GetName() %>
                    <%= Html.RadioButtonFor(p => p.Type, Code.Models.UserType.Surrogate, new { id = "Type_Surrogate", onclick = "rdo_click(1)" })%>
                    <%= UserType.Surrogate.GetName()%>
                </span></li>
            <li>
                <label class="label">
                    用户名：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.LoginName, new { @class = "input_Text", validate = "{required:true,regex:'[0-9a-zA-Z]{4,10}',messages:{required:'*',regex:'格式不正确'}}" })%>
                    <font>必须由数字和字母组成且长度为4-10位</font>
                    <%=Html.ValidationMessageFor(p => p.LoginName)%>
                </span></li>
            <li>
                <label class="label">
                    登录密码：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p=>p.LoginPwd, new { @class = "input_Text",type="password", validate = "{required:true,regex:'.{6,12}',messages:{required:'*',regex:'格式不正确'}}" }) %>
                    <font>密码长度为6-12位</font>
                    <%=Html.ValidationMessageFor(p=>p.LoginPwd) %>
                </span></li>
            <li>
                <label class="label">
                    确认密码：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.ConfirmLoginPwd, new { @class = "input_Text", type = "password", validate = "{required:true,equalTo:'#LoginPwd',messages:{required:'*',equalTo:'两次输入不一至'}}" })%>
                    <font>密码长度为6-12位</font>
                    <%=Html.ValidationMessageFor(p => p.ConfirmLoginPwd)%>
                </span></li>
            <li>
                <label class="label">
                    奖金(百分比)：</label>
                <span class="spans">
                    <%=Html.TextBoxFor(p => p.WinMoneyMargin, new { @class = "input_Text", validate = "{range:[0,100],messages:{range:'0-100之间的数字'}}" })%>%
                    <font>默认:100,跟据您的奖金乘以该比率得出奖金差</font>
                    <%=Html.ValidationMessageFor(p => p.WinMoneyMargin)%>
                </span></li>
        </ul>
         <div>
           
            <br />
          我的返点详情：
            <table class="table" width="100%">
                <%
                var groupwin = Model.Options.GroupBy(p => new { Name=p.WinMoneyName ,ID=p.Option.WinMoneyModelID});
                var wins = groupwin.Select(p => p.Key).OrderBy(p=>p.ID).ToArray();
                var backMoney = Model.Options.GroupBy(p => new { BackName = p.BackMoneyName,BackID = p.Option.BackMoneyTypeID});
                var moneys = backMoney.Select(p => p.Key).OrderBy(p => p.BackID).ToArray(); %>
                <tr>
                    <th>
                     类型\ 模式
                    </th>
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                   
                        <%=item.Name %>
                    </th>
                    <% } %>
                </tr>
                <% var single = groupwin.First().OrderBy(p => p.Option.BackMoneyTypeID).Select(p => new { p.PlayNames, p.Option.BackMoneyTypeID, p.Option.WinMoneyModelID }); %>
                <% foreach (var pl in moneys)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.BackName%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var i = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackID && p.Option.WinMoneyModelID == win.ID ); %>

                    <% var item = Model.Options[i]; %>
                   
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.CurrentBackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                        <%=Html.Encode(item.CurrentBackMoneyRatio)%>
                        
                        <% } %>
                    </td>
                    <% } %>
                </tr>

              <%} %>
            </table>
            <br />
          会员返点设置：
            <br />
             <table class="table" width="100%">
             
                <tr>
                    <th rowspan="2">
                     类型\ 模式
                    </th>
                    <% foreach (var item in wins) %>
                    <% { %>
                    <th colspan='2'>
                    <% var result = Array.FindIndex(Model.Options, p => p.Option.WinMoneyModelID == item.ID); %>
                        <%=item.Name %>
                        <%
                           if (Model.Options[result].Option.WinMoneyState == true &&  Code.BLL.PlayTypeOptionManage.SelectFromOption_SetById())
                           {  %>
                            &nbsp;&nbsp;
                        <%= Html.CheckBoxFor(p => p.Options[result].States, "State")%>
                        <%} %>
               
                          
                    </th>
                    <% } %>
                </tr>
                <tr>
                
                </tr>
                <% foreach (var pl in single)%>
                <% { %>
                <tr>
                    <td>
                        <%=pl.PlayNames%>
                    </td>
                
                    <% foreach (var win in wins)%>
                    <% { %>
                    <% var num = Array.FindIndex(Model.Options, p => p.Option.BackMoneyTypeID == pl.BackMoneyTypeID && p.Option.WinMoneyModelID == win.ID ); %>
                      
                    <% var item = Model.Options[num]; %>
                    
                    <td class='<%=win.ID + "BackMoney"%>' colspan="2">
                        <%=Html.HiddenFor(p => p.Options[num].Option.WinMoneyModelID)%>
                      <%=Html.HiddenFor(p => p.Options[num].Option.BackMoneyTypeID)%>
                        <%if (Model.UseSiteBackMoneyRatio) %>
                        <% { %>
                        <%=item.Option.BackMoneyRatio%>
                        <% } %>
                        <% else %>
                        <% { %>
                        <%=Html.TextBoxFor(p => p.Options[num].Option.BackMoneyRatio, new { @class = "text50"})%>
                        <%=Html.ValidationMessageFor(p => p.Options[num].Option.BackMoneyRatio)%>
                        <% } %>
                    </td>
                    <% } %>
                </tr>
              <%} %>
               
            </table>
    </div>
        <div class="div_AddChildConfig">
            <ul class="editlist">
                <li class="li_AddChildConfig">
                    <label class="label"><font color="red" size='3'>代理配额设置</font></label>
                </li>
                <li class="li_AddChildConfig">
                    <label class="label" style=" float:none; margin:0px 15px 0px 15px;">所有下级数量:</label>
                    <%=Html.TextBoxFor(p=>p.AllChildCount, new {  @class ="input_Text text50", validate = "{range:[0,100000000],messages:{range:'大于等于零的数字'}}" }) %>
                </li>
            </ul>
        </div>
        <ul class="editlist">
            <li class="btn">
                <input type="submit" value="添加" onclick="return btnSubmit_Click()" />&nbsp;&nbsp;<input
                    type="reset" value="重置" />
            </li>
            <%--<li>
                <label class="label">
                    奖金/返点设置：</label>
                <div class="spans">
                </div>
            </li>--%>
        </ul>
        <%--<%
            var groupwin = Model.Options.GroupBy(p => p.WinMoneyName).OrderBy(p=>p.Key);
            var wins = groupwin.Select(p => p.Key).ToArray();
        %>
        <div id="div_options">
            <ul>
                <% foreach (var item in wins) %>
                <% { %>
                <li><a href='#WinModel:<%=item %>'><span>
                    <%=item %></span></a></li>
                <% } %>
            </ul>
            <% foreach (var item in groupwin) %>
            <% { %>
            <div class="groupls" id='WinModel:<%=item.Key %>'>
                <% var grouplot = item.GroupBy(p => p.Option.LotteryID).OrderBy(p=>p.Key).OrderBy(p=>Model.Lotterys[p.Key].Value); %>
                <% foreach (var pls in grouplot) %>
                <% { %>
                <div id="<%=pls.Key %>">
                    <table width="100%" style="border: 1px solid #888888">
                        <tr class="rtsubhaid">
                            <td width="180">
                                <div style="border: 1px solid #8d8d8d; width: 10px; display: inline-block;">+</div>
                                <%=Model.Lotterys[pls.Key].Key %>
                            </td>
                            <td>
                                奖金<input type="text" class="text80" name="<%=item.Key + "AllWinMoney" + pls.Key %>" value='<%=Request[item.Key + "AllWinMoney" + pls.Key] ?? "100" %>' modelid='WinMoney' validate="{number:true,range:[0,999999999],messages:{number:'',range:''}}" />%
                            </td>
                            <td>
                                返点<input type="text" class="text80" name="<%=item.Key + "AllBackMoney" + pls.Key %>" value='<%=Request[item.Key + "AllBackMoney" + pls.Key] ?? "100" %>' modelid='BackMoney' validate="{number:true,range:[0,999999999],messages:{number:'',range:''}}" />%
                            </td>
                        </tr>
                        <% var oderbypls = pls.OrderBy(p => p.Option.PlayTypeListID).OrderBy(p => p.PlaySort); %>
                        <% foreach (var pl in oderbypls) %>
                        <% { %>
                        <% var i = Array.FindIndex(Model.Options, p => p.Option == pl.Option); %>
                        <tr>
                            <td><%=pl.PlayName %></td>
                            <td class="tdWinMoney" title='站点的奖金:<%=pl.CurrentWimMoney %>'>
                                <%=Html.HiddenFor(p=>p.Options[i].Option.PlayTypeID) %>
                                <%=Html.HiddenFor(p=>p.Options[i].Option.WinMoneyModelID) %>
                                <%=Html.TextBoxFor(p => p.Options[i].Option.WinMoney, new { @class = "text80", oldvalue=pl.MaxWinMoney, validate = string.Format("{{required:true,number:true,min:{0},max:{1},messages:{{required:'*',number:'*',min:'>={0}',max:'<={1}'}}}}", pl.MinWinMoney, pl.MaxWinMoney) })%>
                                <%=Html.ValidationMessageFor(p => p.Options[i].Option.WinMoney)%>
                                <%=string.Format("范围{0}~{1}",pl.MinWinMoney,pl.MaxWinMoney) %>
                            </td>
                            <td class="tdBackMoney" title='站点的返点:<%=pl.CurrentBackMoneyRatio %>%'>
                                <%=Html.TextBoxFor(p => p.Options[i].Option.BackMoneyRatio, new { @class = "text80", oldvalue=pl.MaxBackMoneyRatio, validate = string.Format("{{required:true,number:true,min:{0},max:{1},messages:{{required:'*',number:'*',min:'>={0}',max:'<={1}'}}}}", pl.MinBackMoneyRatio, pl.MaxBackMoneyRatio) })%>
                                <%=Html.ValidationMessageFor(p => p.Options[i].Option.BackMoneyRatio) %>%
                                <%=string.Format("范围{0}~{1}",pl.MinBackMoneyRatio,pl.MaxBackMoneyRatio) %>
                            </td>
                        </tr>
                        <% } %>
                    </table>
                    <br />
                </div>
                <% } %>
            </div>
            <% } %>
        </div>--%>
    </fieldset>
    <% Html.EndForm(); %>
</asp:Content>
